﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using System.Xml;

namespace Media
{
    /// <summary>
    /// Object containing informations about a movie media file
    /// </summary>
    public class MovieInfo : AMediaInfo
    {
        #region "Constructeurs"
        /// <summary>
        /// Used for serialization. Use MovieInfo(String path, Taglib.File f) instead
        /// </summary>
        public MovieInfo()
            : base()
        {
        }
        
        /// <summary>
        /// Create a new Movieinfo and get all information about the file at the path
        /// </summary>
        /// <param name="path">Path of the file</param>
        /// <param name="f">object created by Taglib sharp containing all informations about the file</param>
        public MovieInfo(String path, TagLib.File f)
            : base(path, f)
        {
            if (file != null)
            {
                if (file.Properties != null)
                {
                    if (file.Properties.Duration != null)
                        Length = file.Properties.Duration.ToString();
                        BitRates = file.Properties.AudioBitrate.ToString();
                        Dimension = file.Properties.VideoWidth.ToString() + "x" + file.Properties.VideoHeight.ToString();
                }
                if (file.Tag != null)
                    Title = file.Tag.Title;
                if (String.IsNullOrEmpty(Title) == true)
                {
                    Title = Path.GetFileNameWithoutExtension(path);
                }
            }
        }
        #endregion

    }
}
